package br.edu.ufcg.greengrid.model.job.scheduler;

import java.util.Collections;
import java.util.Comparator;
import java.util.List;

import br.edu.ufcg.greengrid.model.machine.Machine;

public class FastestMachineJobScheduler extends DummyJobScheduler {

	protected List<Machine> orderMachines(List<Machine> machines) {

		Collections.sort(machines, new Comparator<Machine>() {

			@Override
			public int compare(Machine m1, Machine m2) {

				if (m1.getOperationsPerSecond() != m2.getOperationsPerSecond()) {
					return m1.getOperationsPerSecond() - m2.getOperationsPerSecond() > 0 ? -1 : 1;
				}

				return 0;
			}

		});

		return machines;
	}
}
